"""author: wenyao
   data: 2021/11/5
   project: cjh
"""
#元组
#有序的项目集合
#可以存放任何数据类型
#不可变数据类型

#内建函数  工厂函数（类型转换）
#
##########################元组的定义##############
#只有一个元素，需要在元素后面加逗号
# >>> tu1 = ()
# >>> type(tu1)
# <class 'tuple'>
# >>> tu2 = tuple()
# >>> type(tu2)
# <class 'tuple'>
# >>> tu1
# ()
# >>> tu2
# ()
# >>> tu3 = tuple("abc")
# >>> tu3
# ('a', 'b', 'c')
# >>> tu4 = (1,)
# >>> type(tu4)
# <class 'tuple'>
# >>> tu5 = (1)
# >>> type(tu5)
# <class 'int'>

#元组里面包含列表，列表是可以改变的，因为列表是可变数据类型，列表里的元素更改不会改变列表本身
# >>> tu1.count(2)
# 3
# >>> tu1.index(2)
# 0
# >>> tu1.index(23)
# 3
# >>> tu1 = ("a",1,None,[3,4])
# >>> tu1[3]
# [3, 4]
# >>> tu1[3].append(4)
# >>> tu1
# ('a', 1, None, [3, 4, 4])
# >>> tu1[0] = "b"
# Traceback (most recent call last):
#   File "<stdin>", line 1, in <module>
# TypeError: 'tuple' object does not support item assignment

#返回的是元组，可以用多个参数接受元组中的每一个元素
# >>> tu1 = (1,2)
# >>> i,j = (1,2)
# >>> i
# 1
# >>> j
# 2
# >>> for i in enumerate(tu1):
# ...    print(i)
# ...
# (0, 1)
# (1, 2)
# >>> for i,j in enumerate(tu1):
# ...    print(i,j)
# ...
# 0 1
# 1 2
# >>>




